﻿
@{
    ViewBag.Title = "Add";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<form id="formAdd">
    名称：<input type="text" name="name" id="name"/>
    描述：<input type="text" name="description" id="description"/>
       <input type="button" value="保存" id="btnSave"/>
</form>

@section FooterScript
{
<script type="text/javascript">
    var saveAjax = function () {
        var formData = $("#formAdd").serializeArray();
        console.log(formData);
        $.ajax({
            url: "/Permission/Add",
            type: "post",
            /*data: {
                name: $("#name").val(),
                description: $("#description").val()
            },*/
            data:formData,
            dataType: "json",
            success: function (res) {
                if (res.status == "ok") {
                    //alert("ok");
                    parent.location.reload();
                } else {
                    alert("error");
                }
            },
            error: function () { alert("ajax error")}
        });
    }
    $(function () {
        $("#btnSave").click(saveAjax);
    });
    </script>
    }
